package outbound.packing.dataObjects
{
	import mx.collections.ArrayCollection;

	[Bindable]
	public class PackingDS
	{
		public var INTERNAL_SHIPMENT_NUM:Number = 0;
		public var INTERNAL_SHIPMENT_LINE_NUM:Number = 0;
		public var INTERNAL_CONTAINER_NUM:Number = 0;
		public var CONTAINER_ID:String = "";
		public var CONTAINER_TYPE:String = "";
		public var TOTAL_QTY:Number = 0;
		public var ATTRIBUTE_NUM:Number = 0;
		public var ITEM:String = "";
		public var ITEM_DESC:String = "";
		public var COMPANY:String = "";
		public var ATTRIBUTE1:String = "";
		public var ATTRIBUTE2:String = "";
		public var ATTRIBUTE3:String = "";
		public var ATTRIBUTE4:String = "";
		public var PACK_PENDING_QTY:Number = 0;
		public var QUANTITY:Number = 0;

		public function PackingDS()
		{
		}
		
		public function Init(xmlObj:XML):void{			
			if(null == xmlObj)
				return;
			else{
				for each (var itemProp:XML in xmlObj.children()) {
					this[itemProp.name()] = itemProp;
				}
				this.QUANTITY = this.PACK_PENDING_QTY;
			}
		}
		
		public function ToXML():String{
			var xmlObj:XML = 
				<PackingDS>			
					<INTERNAL_SHIPMENT_NUM>{INTERNAL_SHIPMENT_NUM}</INTERNAL_SHIPMENT_NUM>
					<INTERNAL_SHIPMENT_LINE_NUM>{INTERNAL_SHIPMENT_LINE_NUM}</INTERNAL_SHIPMENT_LINE_NUM>
					<INTERNAL_CONTAINER_NUM>{INTERNAL_CONTAINER_NUM}</INTERNAL_CONTAINER_NUM>
					<CONTAINER_ID>{CONTAINER_ID}</CONTAINER_ID>
					<CONTAINER_TYPE>{CONTAINER_TYPE}</CONTAINER_TYPE>
					<QUANTITY>{QUANTITY}</QUANTITY>
					<ATTRIBUTE_NUM>{ATTRIBUTE_NUM}</ATTRIBUTE_NUM>
				</PackingDS>;
			return xmlObj;
		}		
		
		public static function getPackingDSes(list:XMLList):ArrayCollection
		{
			var ac:ArrayCollection = new ArrayCollection();
			for each(var xml:XML in list)
			{
				var itm:PackingDS = new PackingDS();
				itm.Init(xml);
				ac.addItem(itm);
			}
			return ac;
		}
	}
}